import axios from 'axios'
const mutations = {
    /**
     * 获取分享信息
     * @param {*} state
     * @param {*} data
     */
    getShareInfo(state,data){
        let callback;
        if (data && data.hasOwnProperty("callback")) {
            callback = data.callback;
            delete (data.callback);
        }
        axios.get('/api/auth/getShareInfo',{
            params:data
        })
        .then( (response)=> {
            /**
             * 如果存在回调
             * @param  {Function} callback [description]
             * @return {[type]}            [description]
             */
            state.shareInfo = response.data.data;
            if (callback) {
                callback(response.data, data);
            }
        })
    },
    /**
     * 保存抢票信息
     * @param {*} state
     * @param {*} data
     */
    saveTicketInfo(state,data){
        let callback;
        if (data && data.hasOwnProperty("callback")) {
            callback = data.callback;
            delete (data.callback);
        }
        axios.post('/api/ticket/saveVolunteer',data)
        .then( (response)=> {
            /**
             * 如果存在回调
             * @param  {Function} callback [description]
             * @return {[type]}            [description]
             */
            if (callback) {
                callback(response.data, data);
            }
        })
    },
    /**
     * 获取抢票信息
     * @param {*} state
     * @param {*} data
     */
    getTicketInfo(state,data){
        let callback;
        if (data && data.hasOwnProperty("callback")) {
            callback = data.callback;
            delete (data.callback);
        }
        axios.post('/api/ticket/getQp',data)
        .then( (response)=> {
            /**
             * 如果存在回调
             * @param  {Function} callback [description]
             * @return {[type]}            [description]
             */
            state.ticketInfo = response.data.data;
            if (callback) {
                callback(response.data, data);
            }
        })
    },

}
export default mutations;
